/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment_cp3120.ucm;

import assignment_cp3120.startup.StartupView;
import assignment_cp3120.viewtickets.ViewTicketsModel;
import assignment_cp3120.viewtickets.ViewTicketsView;
import java.sql.Date;
/**
 * 1. User presses view tickets button
 * 2. System retrives the avalible tickets for the current date onwards from database
 * 3. System displays the view panel
 * 
 * a. User presses cancel button
 * b. System shows welcome screen
 * 
 * 2.a.1 System cannont connect to the database
 * 2.a.2 System loads hardcoded flight details
 * @author Administrator
 */
public class UCViewTickets implements UseCaseController{
    private ViewTicketsModel model;
    private ViewTicketsView view;
    /**
     * Defualt constructor, calls the Constructor(view,model,frame) with new values for each
     */
    public UCViewTickets(){
        this(new ViewTicketsView(), new ViewTicketsModel());
    }
    /**
     * Constructor that sets the view,model and frame to the inputs. Also loads the avalible flights.
     * Avalible flights are those that are from today onwards
     * @param view
     * @param model
     * @param mainFrame
     */
    public UCViewTickets(ViewTicketsView view, ViewTicketsModel model) {
        this.model = model;
        this.view = view;
        Date today = new Date(System.currentTimeMillis());
        model.loadFlightsFromDate(today);
        
    }
    /**
     * Starts the uc, sets the contents of the frame to the view and the subtitle
     */
    public void run(){
        StartupView.getInstance().setContents(view.createView());
        StartupView.getInstance().setSubTitle(view.getTitleLabel().getText());
    }
}
